# coding=utf-8
# 全世界最帅的帅哥
from flask_restful import Resource
from ysgg1_club_auth.auth_views.permission_views import (create_permission, update_permission,
                                                         delete_permission, disable_or_enable_permission,
                                                         show_or_hide_permission)
from ysgg1_club_comment.utils.fbmsg import FBMsg


class PermissionResource(Resource):

    def post(self, action=None):
        """
        新增权限
        :return:
        """
        if action == "change_show":
            return show_or_hide_permission()
        elif action == "change_permission":
            return disable_or_enable_permission()
        return create_permission()

    def put(self, permission_id=None):
        """
        修改权限
        :return:
        """
        if permission_id:
            return update_permission(permission_id)
        return FBMsg.error_param()

    def delete(self, permission_id=None):
        """
        删除权限
        :param permission_id:
        :return:
        """
        if permission_id:
            return delete_permission(permission_id)
        return FBMsg.error_param()


